<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <canvas id="myCanvas" tabindex="0"></canvas>
  <script>
    Module = {};
    Module.onRuntimeInitialized = function () {
      var image = new Image();
      image.src = "cover.png";
      image.onload = function () {
        var canvas = document.getElementById('myCanvas');
        var ctx = canvas.getContext("2d");
        canvas.width = image.width;
        canvas.height = image.height;
        ctx.drawImage(image, 0, 0);

        canvas.addEventListener("keydown", onKeyDown, true);
        canvas.focus();
      }
    }

    function onKeyDown(event) {
      Module.ccall('on_key_down', 'null', ['string'], [event.key]);
    }
  </script>
  <script src="keyEvent.js"></script>
</body>

</html>